package com.company.设计模式.单例模式;

/**
 * @author uguoy089
 * @Description:
 * @Date: 2021/5/11 09:08
 */

public class Singleton3 {
    private volatile static Singleton3 instance;

    private Singleton3() {
        System.out.println("双重检查模式 (DCL)");
    }

    public static Singleton3 getInstance() {
        if (instance == null) {
            synchronized (Singleton3.class) {
                if (instance == null) {
                    instance = new Singleton3();
                }
            }
        }
        return instance;
    }
}
